package com.itheima.service.impl;


import com.github.pagehelper.Page;
import com.github.pagehelper.PageHelper;
import com.itheima.dao.SportsDao;
import com.itheima.entity.PageResult;
import com.itheima.entity.QueryPageBean;
import com.itheima.pojo.Sports;
import com.itheima.service.SportsService;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.transaction.annotation.Transactional;

@Service(interfaceClass = SportsService.class)
@Transactional
public class SportsServiceImpl implements SportsService {
    @Autowired
    private SportsDao sportsDao;

    @Override
    public PageResult queryPage(QueryPageBean queryPageBean) {
        PageHelper.startPage(queryPageBean.getCurrentPage(),queryPageBean.getPageSize());
        Page<Sports> sports = sportsDao.selectByCondition(queryPageBean.getQueryString());
        return new PageResult(sports.getTotal(),sports.getResult());
    }

    @Override
    public void add(Sports sports) {
        sportsDao.add(sports);
    }
}
